<!--
 * @Description  : 数据更新与维护 
 * @Author       : zhao
 * @Date         : 2022-07-14 10:52:43
 * @LastEditors  : zhao
 * @LastEditTime : 2023-01-29 16:58:04
-->
<template>
    <div class="updataMaintain">

        <ztable :searchType="searchType" :tableHeader="tableHeader" :tableData="tableData" :title="'数据更新与维护'" />
    </div>
</template>

<script setup lang='ts'>
import { ref, onMounted, toRaw } from 'vue';
import ztable from '/@/components/zTable/index.vue';
import BFData from '/@/views/zUpdataAndMaintain/updataMaintain.ts';
import { useTableInfo } from '/@/stores/ztable'
import { useUpdataMaintain } from '/@/stores/updataMaintain'

const searchType = ref(BFData.searchType);
const tableHeader = ref(BFData.tableHeader);
const tableData = ref(BFData.tableData);

const { zTable, zTableFunction, getTableData } = useTableInfo()
let useTableInfos = useTableInfo()
let useUpdataMaintains = useUpdataMaintain()
const initData = async () => {
    useTableInfos.$reset()
    useTableInfos.zTable.routerUrl = "/updataAndMaintain/details"
    useTableInfos.zTableFunction.upload = true
    useTableInfos.zTableFunction.delete = true
    useTableInfos.zTableType.selection = true
    useTableInfos.zTableType.border = true
    useTableInfos.zTable.mdName.name = "useUpdataMaintain"
    useTableInfos.zTable.mdName.url = "getArchiveList"
    await getTableData()
}
initData()


const del = async () => {
    // editUserRef.value.openDialog();

    const row = toRaw(useTableInfos.zTable.selectRows)
    let arr = row.map((e: any) => { return e.id })
    const res = await useUpdataMaintains.DeleteArchiveDataList({ id: arr })
    getTableData()
    useTableInfos.zTableFunDelShow = false
}
useTableInfos.$subscribe((mutation: any, state) => {
    const sta = toRaw(state)

    if (sta.zTableFunDelShow) del()

})
</script>
<style lang='scss' scoped>
</style>